package com.cj.bk_app.model.api

import com.cj.bk_app.model.bean.*
import retrofit2.http.*

interface BKService {

    companion object {
        const val BASE_URL = "http://192.168.182.202:8089/jeecg-boot/"
    }

    @GET("books/list")
    suspend fun getHomeBooks(@Query("pageNo") page: Int): BKResponse<BKResponsePage<Book>>

    @GET("book/{id}")
    suspend fun getBookById(@Path("id") id: Int): BKResponse<Book>

    @FormUrlEncoded
    @POST("book")
    suspend fun addBook(@FieldMap params: Map<String,String>): BKResponse<Any>

    @FormUrlEncoded
    @PUT("book")
    suspend fun editBook(@FieldMap params: Map<String,String>): BKResponse<Any>


    @DELETE("book/{id}")
    suspend fun deleteBookById(@Path("id") id: Int): BKResponse<Any>

    @FormUrlEncoded
    @POST("user/login")
    suspend fun login(@Field("username") userName: String, @Field("password") passWord: String): BKResponse<User>

    @GET("user/logout/json")
    suspend fun logOut(): BKResponse<Any>

    @FormUrlEncoded
    @POST("user/register")
    suspend fun register(@Field("username") userName: String, @Field("password") passWord: String, @Field("repassword") rePassWord: String): BKResponse<User>
}